#pragma once
#include "../Comm/Comm.h"
//多线程中唯一实例,设计为单例模式:懒汉模式

class CentralCache
{
public:
    static CentralCache* GetInstance();
    
    //获取一个span
    Span* GetSpan(SpanList& spanList,size_t alignSize,size_t batchNum);
    //从CentralCache中获取一定数量的内存空间给ThreadCache
    size_t FetchRangeObj(void*& start,void*& end,size_t alignSize,size_t batchNum,size_t index);

    void ReleaseToCentral(void* start,size_t size);
private:
    CentralCache();
    ~CentralCache() = default;
    CentralCache(const CentralCache&) = delete;
    CentralCache& operator=(const CentralCache&) = delete;
private:
    SpanList _spanLists[NFREELISTS];
    static CentralCache _sInt;//饿汉模式,具体定义在cpp文件中,防止重定义
};